package pack;
import java.util.Random;


public class SystemArrayCopyVsForCopy {

	public static void main(String[] args) {
		
		int[] COUNT = {1000,10000,100000,1000000,10000000};
		int HEAT = 1000000;
		for(int j = 0; j < 5; j++) {
			
			
			int count = COUNT[j];
			int[] heat = new int[HEAT];
			int[] array = new int[count];
			int[] copyArray = new int[count];
			int[] copySystemArray = new int[count];
			Random rand = new Random();
			long copyWithFor = 0;
			long copyWithSystem = 0;

			for(int i = 0 ; i < HEAT; i++) {
				heat[i] = rand.nextInt();	
			}
			
			for(int i = 0 ; i < count; i++) {
				array[i] = rand.nextInt();		
			}
			
			copyWithFor -= System.nanoTime();
			for (int i = 0; i < count; i++) {
				copyArray[i] = array[i];
			}
			copyWithFor += System.nanoTime();
			
			
			copyWithSystem -= System.nanoTime();
			System.arraycopy(array, 0, copySystemArray, 0, count-1);
			copyWithSystem += System.nanoTime();
			
			System.out.println((double)copyWithFor/copyWithSystem);
			System.out.println(copyWithFor);
			System.out.println(copyWithSystem);
		}
	}
}
